<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Account information class.
 *
 * Account information's CRUD.
 */
class Db_admin_model extends CI_Model
{
	private $db_name = 'k9deploy_new';
	private $table = 'db_info';
	private $db = null;
	
	/**
	 * Constructor
	 *
	 * Sets the database used for saving account information.
	 */
	public function __construct()
	{
		parent::__construct();
		
		$this->db = $this->load->database($this->db_name, TRUE);
	}

	public function db_add($data)
	{
		$count = count($this->db->get_where($this->table,array('db_name'=>$data['db_name']))->result_array());
		if($count!='0'){
			return 1;
		}else{
			$this->db->insert($this->table,$data);
			return 0;
		}
	}

	public function get_db_info()
	{
		$db_info = $this->db->get($this->table)->result_array();
		return $db_info;
	}
}
